Skip to content

feat(testing): snapshot tests, SEP-24 integration, API coverage enforcement, and webhook chaos tests#1035

Merged
Haroldwonder merged 2 commits into
Haroldwonder:mainfrom
rejoicetukura-blip:feat/issues-927-928-930-931-testing-infrastructure
Jun 30, 2026
Merged

feat(testing): snapshot tests, SEP-24 integration, API coverage enforcement, and webhook chaos tests#1035
Haroldwonder merged 2 commits into
Haroldwonder:mainfrom
rejoicetukura-blip:feat/issues-927-928-930-931-testing-infrastructure

Conversation

@rejoicetukura-blip

@rejoicetukura-blip rejoicetukura-blip commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR implements the full test infrastructure requested across four issues, covering frontend visual regression, SEP-24 flow integration, API coverage enforcement, and webhook reliability under adverse network conditions.


closes #931 — Frontend Snapshot Tests

What was added

  • Four React components built from scratch: SendMoneyFlow, TransactionHistory, AgentPanel, CorridorAnalytics
  • Vitest snapshot tests for each component covering loading, empty, populated, and interactive states (20 snapshot assertions total)
  • Storybook 8 stories wired alongside each component for visual review (Default, Loading, Empty, variant stories)
  • frontend/vitest.config.ts configured with jsdom environment, V8 coverage, and snapshot format options
  • CI workflow (.github/workflows/frontend-snapshot-tests.yml) that runs snapshots on every PR touching frontend/, builds Storybook, and fails if any snapshot would change without a deliberate update

Snapshot update workflow: run npm run test:snapshot:update inside frontend/, review the diff, commit.


closes #928 — API Service Coverage Reporting

What was added

  • api/vitest.config.ts — V8 coverage provider with thresholds: 80% lines, 75% branches, 80% functions, 80% statements
  • npm run test:coverage script added to api/package.json
  • CI workflow (.github/workflows/api-coverage.yml) that:
    • Runs vitest run --coverage on every PR touching api/
    • Publishes a per-metric pass/fail table to the GitHub Actions step summary
    • Fails the build if any threshold is breached
    • Uploads the full HTML coverage report as a build artifact

closes #927 — SEP-24 Deposit Integration Tests

What was added

  • api/src/services/sep24.tsSep24Client class: initiateDeposit(), getTransaction(), pollUntilComplete() (with configurable interval/timeout)
  • api/src/__tests__/sep24.test.ts — unit tests using mocked axios (happy path, expiry, refund, timeout, header assertions)
  • api/src/__tests__/sep24-deposit.integration.test.ts — integration test suite that runs against a real Anchor Platform:
    • Initiate → interactive URL → HTTP reachability check → poll → completed (happy path)
    • Expiry path: poll reaches expired terminal state
    • Refund path: poll reaches refunded with refunds object populated
  • tests/docker/sep24-docker-compose.yml — Anchor Platform 3.0.0 + Stellar Quickstart for local/CI reproduction
  • api/vitest.integration.config.ts — separate Vitest config with 120s timeout for integration suite
  • CI workflow (.github/workflows/sep24-integration-tests.yml) — nightly cron at 02:00 UTC; spins up Docker, obtains SEP-10 JWT, runs integration tests, tears down and publishes summary

Local run:

docker-compose -f tests/docker/sep24-docker-compose.yml up -d
cd api && ANCHOR_PLATFORM_URL=http://localhost:8080 npm run test:integration

closes #930 — Webhook Chaos Tests

What was added

  • api/src/services/webhook.tsdeliverWebhook() with exponential backoff (baseDelay × 2^attempt, capped at maxDelayMs), configurable retry count, per-event timeout, and an in-memory DLQ; getDLQ() / clearDLQ() for test inspection
  • api/src/__tests__/webhook.test.ts — unit tests: success on first attempt, retry on 503, DLQ after exhausting retries, no retry on 4xx, correct headers, multiple independent DLQ entries
  • api/src/__tests__/webhook-chaos.chaos.test.ts — chaos tests using Toxiproxy management API:
    • Baseline (no fault) — delivers on attempt 1
    • +1 s latency (latency toxic) — delivers within timeout
    • Connection reset (reset_peer toxic) — retries and DLQs after max retries
    • 30 s timeout (timeout toxic, 3 s webhook timeout fires first) — DLQs after max retries
    • Exponential backoff — delay array extracted from setTimeout spy grows monotonically
  • tests/docker/chaos-docker-compose.yml — Toxiproxy 2.9.0 + Node echo server
  • tests/docker/webhook-echo-server.js — minimal HTTP echo server (POST /webhook → 200, GET /health → 200)
  • api/vitest.chaos.config.ts — sequential fork pool (Toxiproxy state is shared), 180 s timeout
  • CI workflow (.github/workflows/webhook-chaos-tests.yml) — nightly cron at 03:00 UTC; provisions infrastructure, runs chaos suite, publishes fault/behaviour table to step summary

Local run:

docker-compose -f tests/docker/chaos-docker-compose.yml up -d
cd api && TOXIPROXY_URL=http://localhost:8474 WEBHOOK_PROXY_PORT=9090 \
  WEBHOOK_TARGET_URL=http://localhost:3001 npm run test:chaos

Files changed

Path Purpose
frontend/ React components + Vitest snapshots + Storybook (#931)
api/src/services/webhook.ts Webhook delivery with backoff + DLQ (#930)
api/src/services/sep24.ts SEP-24 client (#927)
api/src/__tests__/webhook.test.ts Webhook unit tests (#930)
api/src/__tests__/sep24.test.ts SEP-24 unit tests (#927)
api/src/__tests__/sep24-deposit.integration.test.ts SEP-24 integration tests (#927)
api/src/__tests__/webhook-chaos.chaos.test.ts Toxiproxy chaos tests (#930)
api/vitest.config.ts V8 coverage thresholds (#928)
api/vitest.integration.config.ts Integration test config (#927)
api/vitest.chaos.config.ts Chaos test config (#930)
tests/docker/sep24-docker-compose.yml Anchor Platform Docker stack (#927)
tests/docker/chaos-docker-compose.yml Toxiproxy + echo server Docker stack (#930)
tests/docker/webhook-echo-server.js Webhook echo target (#930)
.github/workflows/frontend-snapshot-tests.yml Frontend CI (#931)
.github/workflows/api-coverage.yml Coverage CI (#928)
.github/workflows/sep24-integration-tests.yml SEP-24 nightly CI (#927)
.github/workflows/webhook-chaos-tests.yml Chaos nightly CI (#930)

Closes #931
Closes #928
Closes #927
Closes #930

…ting, and chaos tests

Closes Haroldwonder#931 — Vitest snapshot tests for SendMoneyFlow, TransactionHistory, AgentPanel,
and CorridorAnalytics; Storybook 8 stories for visual regression; CI workflow enforces
snapshot freshness on every PR.

Closes Haroldwonder#928 — Vitest V8 coverage provider with 80% line / 75% branch thresholds;
--coverage wired into CI; coverage report published to GitHub Actions PR summary.

Closes Haroldwonder#927 — Sep24Client service with initiateDeposit / pollUntilComplete; unit tests
covering the happy path, expiry, and refund flows; integration test suite that runs
against a real Anchor Platform (Docker) in nightly CI with SEP-10 JWT auth; Docker Compose
for local reproduction.

Closes Haroldwonder#930 — WebhookDelivery service with exponential backoff and in-memory DLQ;
Toxiproxy Docker Compose for network fault injection; chaos test suite covering 1s
latency, connection reset, 30s timeout, and backoff growth; DLQ receipt verified under
each fault; runs nightly in CI.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@rejoicetukura-blip is attempting to deploy a commit to the Harold's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@rejoicetukura-blip Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Haroldwonder Haroldwonder merged commit eff08cf into Haroldwonder:main Jun 30, 2026
4 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants